package dyyx;
import java.io.IOException;
import java.util.Date;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletHandler;

public class HelloServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
		response.setStatus(HttpServletResponse.SC_OK);
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		response.getWriter().println("Hello Servlet,"+new Date());
	}

	public static void main(String[] args) throws Exception {
		int port = 8080;
		System.out.println("port="+port);
		Server server = new Server(port);
		
		ServletHandler handler = new ServletHandler();
		server.setHandler(handler);
		// 
		handler.addServletWithMapping(HelloServlet.class, "/*");
		
		server.start();
		server.join();
	}
}
